import Ships.Battleship
import coords
from random import *

# **
# *  'Depositing' is a state class utilised when the Miners cargo hold is full.
# *
# * PUBLIC FEATURES:
# *    // Constructors
# *    def __init__(self)
# *
# *    // Methods
# *    def Enter(self, ship)
# *    def Execute(self, ship)
# *    def Exit(self, ship)
# *    
# *
# *    COLLABORATORS:
# *    Ships.BattleShip
# *
# * MODIFIED:
# * @version 1.1, 2007-05-24
# * @author Julian Andreou 5422329
# * @author Gavan Hunter 5422264
# * @author  Simon Iskra 5422361
# * @author  Joel Schmidt 2660660
# */

class Wandering():
    def __init__(self): 
        self.stateString = "Wandering"
    #  wander wander wander
    #  detect miners and pirates
    #
    #  TRANSITIONS
    #  if security is negative and there is no miners close by then flee
    #  if pirates detected and security is not negative then lock on to a pirate
    #  and state change to 'Attack'
    
    def Enter(self, ship):
       
        validDestination = False
        while not validDestination:
             x = int(uniform(0,31)//1)
             y = int(uniform(0,31)//1)
             if ship.map.getCell([x,y]):
                 ship.path = ship.map.findPath(ship.getGridCoords(), [x,y])
                 validDestination = True
        ship.pathCount = 0
    
    def Execute(self, ship): 
        if ship.pathCount<len(ship.path.nodes):
            ship.position = coords.gridToScreen([ship.path.nodes[ship.pathCount].location.x,ship.path.nodes[ship.pathCount].location.y])
        else:
            self.Enter(ship)
        print str(ship.position)
        print str(ship.myGridCoords)
        ship.pathCount+=1
    
    def Exit(self, ship):
        pass
            